package router

import (
	"iris-wms/apps/admin/web/dto/din"
	"iris-wms/apps/admin/web/service"
	"iris-wms/common/tools/result"

	"github.com/kataras/iris/v12"
)

func NewWmsHistoryRoute() *wmsHistoryRoute {
	return &wmsHistoryRoute{}
}

type wmsHistoryRoute struct{}

func (r *wmsHistoryRoute) GetInAndOutHistory(ctx iris.Context, service_ service.WmsHistoryService) {
	var in din.WmsHistoryTableIn
	if err := ctx.ReadQuery(&in); err != nil {
		ctx.StopWithPlainError(iris.StatusBadRequest, err)
		return
	}
	rows, total, err := service_.GetInAndOutHistory(in)
	if err != nil {
		ctx.StopWithPlainError(iris.StatusInternalServerError, err)
		return
	}
	result.VxeTableData(ctx, in.PageSize, in.CurrentPage, total, rows, nil)
}
